export default class GrassStaticObj extends godot.StaticBody2D {
    constructor(x = 200, y = 200, img = "") {
        super()
        // Area2D  碰撞对象体
        this.position = new godot.Vector2(x, y)

        // Sprite  外观
        var spr = new godot.Sprite()
        if (img) {
            spr.texture = godot.load(img) as godot.Texture
        } else {
            spr.texture = godot.load("res://icon.png") as godot.Texture
        }

        this.add_child(spr);

        // Shape   碰撞盒
        let shape = new godot.RectangleShape2D()
        let w = spr.texture.get_width()
        let h = spr.texture.get_height();
        shape.extents = new godot.Vector2(w / 2, h / 2)

        let oid = this.create_shape_owner(this)
        this.shape_owner_add_shape(oid, shape)
    }
}